package com.itheima.service;

import com.itheima.dao.ProvinceMapper;
import com.itheima.pojo.City;
import com.itheima.pojo.Province;
import com.itheima.utils.SqlSessionFactoryUtils;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

/**
 * @author Xiao
 * @date 2021/9/6
 */
public class ProvinceService {
    public List<Province> selectAllProvince() {
        SqlSession sqlSession = SqlSessionFactoryUtils.getSqlSession();
        ProvinceMapper provinceMapper = sqlSession.getMapper(ProvinceMapper.class);
        List<Province> provinces = provinceMapper.selectAllProvince();
        sqlSession.close();
        return provinces;
    }

    public List<City> selectCityByFID(Integer fatherID) {
        SqlSession sqlSession = SqlSessionFactoryUtils.getSqlSession();
        ProvinceMapper provinceMapper = sqlSession.getMapper(ProvinceMapper.class);
        List<City> cities = provinceMapper.selectCityByFID(fatherID);
        sqlSession.close();
        return cities;
    }
}
